package mango.web.client.admin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mango.web.client.C;
import mango.web.client.View;

import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;

public class AdminLoginView extends View {
	protected static AdminLoginView adminLoginView;

	public static AdminLoginView get(String key) {
		if ("".equals(key)) {
			if (AdminLoginView.adminLoginView == null) AdminLoginView.adminLoginView = new AdminLoginView().init();
			return AdminLoginView.adminLoginView;
		}
		return null;
	}

	public DialogBox dialogBox;
	public Button loginButton;
	public TextBox usernameText;
	public TextBox passwordText;

	public AdminLoginView init() {

		this.panel.setSize("1000px", "570px");

		AbsolutePanel panel;
		Label label;
		HTML html;
		TextBox textBox;
		CheckBox checkBox;
		ListBox listBox;
		RadioButton radioButton;
		TextArea textArea;
		Button button;
		int top;
		int left;

		panel = new AbsolutePanel();
		panel.setSize("1000px", "570px");
		this.panel.add(panel, 0, 0);
		
		html = new HTML("<img src='image/lock.png'></img>");
		panel.add(html, 370, 180);
		
		AbsolutePanel panel2 = new AbsolutePanel();
		panel2.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
		panel2.getElement().getStyle().setBorderWidth(1, Unit.PX);
		panel2.setSize("350px", "150px");
		panel.add(panel2, 300, 100);
		
		left = 30;
		top = 20;
		html = new HTML("<b>User Name</b>");
		panel2.add(html, left, top);
		
		textBox = this.newTextBox("admin", 150);
		panel2.add(textBox, left + 120, top);
		this.usernameText = textBox;
		
		top = 50;
		html = new HTML("<b>Password</b>");
		panel2.add(html, left, top);
		
		textBox = new PasswordTextBox();
		textBox.setWidth("150px");
		panel2.add(textBox, left + 120, top);
		this.passwordText = textBox;
		
		top = 80;
		button = new Button("Login");
		panel2.add(button, left + 120, top);
		this.loginButton = button;
		

		// TODO:AdminSearchView
		this.dialogBox = new DialogBox();
		this.dialogBox.setHTML("<b style='color:red'>Administration</b>");
		this.dialogBox.setModal(false);
		this.dialogBox.setWidget(this.panel);

		return this;
	}

	public AdminLoginView view() {

		return this;
	}
}
